#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 功能：语音检测出来的物品

import rospy

from std_msgs.msg import String
from darknet_ros_msgs.msg import BoundingBoxes


def yolo_detect():
    rospy.init_node('yolodetect', anonymous=True)
    rospy.Subscriber('/darknet_ros/bounding_boxes', BoundingBoxes, callback)
    rospy.spin()


def callback(bboxes):
    bboxes = bboxes.bounding_boxes
    object_name = bboxes[0].Class
    audio_pub = rospy.Publisher('/speak', String, queue_size=1)
    audio_pub.publish('该物品是')
    rospy.sleep(1)
    audio_pub.publish(object_name)
    rospy.loginfo('object name: %s', object_name)
    rospy.sleep(5)


if __name__ == '__main__':
    yolo_detect()
